package ${servicePackage};

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ${impBeanPackage};
import ${impDaoPackage};

@Service("${serviceAnoName}")
@Transactional
public class ${serviceName} {

	@Autowired
	private ${daoName} ${daoName?uncap_first};
	
	/**
	 * 获取任务
	 * @param ${beanName}
	 * @return
	 */
	public ${beanName} get${beanName}ById(${beanName} ${beanName?uncap_first}){
		return  ${daoName?uncap_first}.get${beanName}ById(${beanName?uncap_first});
	}
	
	/**
	 * 添加任务
	 * @param ${beanName}
	 * @return
	 */
	public int add${beanName}(${beanName} ${beanName?uncap_first}){
		return  ${daoName?uncap_first}.add(${beanName?uncap_first});
	}
	
	/**
	 * 更新任务数据${beanName}
	 * @param task
	 * @return
	 */
	public int update${beanName}(${beanName} ${beanName?uncap_first}){
		return  ${daoName?uncap_first}.update${beanName}(${beanName?uncap_first});
	}
	
	/**
	 * 删除 ${beanName}
	 * @param task
	 * @return
	 */
	public int del${beanName}(${beanName} ${beanName?uncap_first}){
		return  ${daoName?uncap_first}.del${beanName}(${beanName?uncap_first});
	}
	
	public Map<String,Object>getPage(String draw,String recordsFilteredSql,String recordsTotalSql,String sql){
		String recordsTotal= ${daoName?uncap_first}.getCountPage(recordsTotalSql);
		String recordsFiltered= ${daoName?uncap_first}.getCountPage(recordsFilteredSql);
		Map<String,Object>result=new HashMap<String,Object>();
		result.put("data",  ${daoName?uncap_first}.getPageAll${beanName}(sql));
		result.put("recordsTotal", recordsTotal);
		result.put("recordsFiltered", recordsFiltered);
		result.put("draw",draw);
		return result;
	}
}
